local skill = fk.CreateSkill {
  name = "#ling__weimo_tu_skill",
  attached_equip = "ling__weimo_tu",
}

Fk:loadTranslationTable {
  ["#ling__weimo_tu-invoke"] = "维摩诘经变图：你可以失去1点体力，翻回正面",
}

local spec = {
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askToSkillInvoke(player, {
          skill_name = skill.name,
          prompt = "#ling__weimo_tu-invoke"
        }) then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:loseHp(player, 1, skill.name)
    if player.dead then return end
    player:turnOver()
  end,
}

skill:addEffect(fk.TurnedOver, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and not player.faceup
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

skill:addEffect(fk.CardUseFinished, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and not player.faceup and
        data.card.name == skill.attached_equip
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

return skill
